<HTML>
<HEAD>
<TITLE>[Chapter 22] RGBImageFilter</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:25:58 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch22_13.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 22<br>java.awt.image Reference</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch23_01.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>RGBImageFilter</H1>

<H2>Name</H2>

RGBImageFilter

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.82"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/rgbimag.gif" alt="[Graphic: Figure from the text]" width=503 height=53 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.83">Description</A></h2>

<P CLASS=para>
<tt CLASS=literal>RGBImageFilter</tt> is an abstract 
class that helps you filter images based on each pixel's color and 
position. In most cases, the only method you need to implement in subclasses 
is <tt CLASS=literal>filterRGB()</tt>, which returns 
a new pixel value based on the old pixel's color and position. <tt CLASS=literal>RGBImageFilter</tt> 
cannot be used to implement filters that depend on the value of neighboring 
pixels, or other factors aside from color and position. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.84">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public abstract class java.awt.image.RGBImageFilter
    extends java.awt.image.ImageFilter {
  // Variables
  protected boolean canFilterIndexColorModel;
  protected ColorModel newmodel;
  protected ColorModel oldmodel;
  // Instance Methods
  public IndexColorModel filterIndexColorModel (IndexColorModel icm);
  public abstract int filterRGB (int x, int y, int rgb);
  public void filterRGBPixels (int x, int y, int width, 
      int height, int[] pixels, int off, int scansize);
  public void setColorModel (ColorModel model);
  public void setPixels (int x, int y, int width, int height, 
      ColorModel model, byte[] pixels, int offset, int scansize);
  public void setPixels (int x, int y, int width, int height, 
      ColorModel model, int[] pixels, int offset, int scansize);
  public void substituteColorModel (ColorModel oldModel, 
      ColorModel newModel);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.85">Variables</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.122">canFilterIndexColorModel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.145">protected boolean canFilterIndexColorModel</A></h4>

<P CLASS=para>
Setting the <tt CLASS=literal>canFilterIndexColorModel</tt> 
variable to <tt CLASS=literal>true</tt> indicates 
the filter can filter <tt CLASS=literal>IndexColorModel</tt> 
images. To filter an <tt CLASS=literal>IndexColorModel</tt>, 
the filter must depend only on color, not on position. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.123">newmodel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.146">protected ColorModel newmodel</A></h4>

<P CLASS=para>
A place to store a new <tt CLASS=literal>ColorModel</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.124">origmodel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.147">protected ColorModel origmodel</A></h4>

<P CLASS=para>
A place to store an old <tt CLASS=literal>ColorModel</tt>. 

</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.86">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.125">filterIndexColorModel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.148">public IndexColorModel filterIndexColorModel (IndexColorModel icm)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>icm</I><br>
<DD>

<P CLASS=para>
Color model to filter. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Filtered color model. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Helper method for <tt CLASS=literal>setColorModel()</tt> 
that runs the entire color table of <tt CLASS=literal>icm</tt> 
through the <tt CLASS=literal>filterRGB()</tt> method 
of the subclass. Used only if <tt CLASS=literal>canFilterIndexColorModel</tt> 
is <tt CLASS=literal>true</tt>, and the image uses 
an <tt CLASS=literal>IndexColorModel</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.126">filterRGB</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.149">public abstract int filterRGB (int x, int y, int rgb)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
x-coordinate of pixel data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
y-coordinate of pixel data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>rgb</I><br>
<DD>

<P CLASS=para>
Color value of pixel to filter. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
New color value of pixel. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Subclasses implement this method to provide a filtering function that generates 
new pixels. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.127">filterRGBPixels</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.150">public void filterRGBPixels (int x, int y, int width, int height, int[] pixels, int off, int scansize)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
x-coordinate of top-left corner of pixel data within 
entire image.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
y-coordinate of top-left corner of pixel data within 
entire image.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
Width of pixel data within entire image.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
Height of pixel data within entire image.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>pixels</I><br>
<DD>

<P CLASS=para>
Image data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>off</I><br>
<DD>

<P CLASS=para>
Offset from beginning of each line in pixels array.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>scansize</I><br>
<DD>

<P CLASS=para>
Size of each line of data in pixels array. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Helper method for <tt CLASS=literal>setPixels()</tt> 
that filters each element of the <tt CLASS=literal>pixels</tt> 
buffer through the subclass's <tt CLASS=literal>filterRGB()</tt> 
method. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.128">setColorModel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.151">public void setColorModel (ColorModel model)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>model</I><br>
<DD>

<P CLASS=para>
The color model for the image. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>ImageFilter.setColorModel(</tt><tt CLASS=literal>ColorModel</tt><tt CLASS=literal>)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Sets the image's color model. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.129">setPixels</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.152">public void setPixels (int x, int y, int width, int height, ColorModel model, byte[] pixels, int offset, int scansize)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
x-coordinate of top-left corner of pixel data delivered 
with this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
y-coordinate of top-left corner of pixel data delivered 
with this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
Width of the rectangle of pixel data delivered with 
this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
Height of the rectangle of pixel data delivered with 
this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>model</I><br>
<DD>

<P CLASS=para>
Color model of image data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>pixels</I><br>
<DD>

<P CLASS=para>
Image data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>offset</I><br>
<DD>

<P CLASS=para>
Offset from beginning of the pixels array.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>scansize</I><br>
<DD>

<P CLASS=para>
Size of each line of data in pixels array. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>ImageFilter.setPixels(</tt><tt CLASS=literal>int, 
int, int, int, ColorModel, byte[], int, int</tt><tt CLASS=literal>)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Called by the <tt CLASS=literal>ImageProducer</tt> 
to deliver a rectangular block of pixels for filtering. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.153">public void setPixels (int x, int y, int width, int height, ColorModel model, int[] pixels, int offset, int scansize)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
x-coordinate of top-left corner of pixel data delivered 
with this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
y-coordinate of top-left corner of pixel data delivered 
with this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
Width of the rectangle of pixel data delivered with 
this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
Height of the rectangle of pixel data delivered with 
this method call.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>model</I><br>
<DD>

<P CLASS=para>
Color model of image data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>pixels</I><br>
<DD>

<P CLASS=para>
Image data.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>offset</I><br>
<DD>

<P CLASS=para>
Offset from beginning of the pixels array.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>scansize</I><br>
<DD>

<P CLASS=para>
Size of each line of data in pixels array. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>ImageFilter.setPixels(</tt><tt CLASS=literal>int, 
int, int, int, ColorModel, int[], int, int</tt><tt CLASS=literal>)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Called by the <tt CLASS=literal>ImageProducer</tt> 
to deliver a rectangular block of pixels for filtering. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch22-REFSECT2-AUTOID.130">substituteColorModel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch22-REFSECT3-AUTOID.154">public void substituteColorModel (ColorModel oldModel, ColorModel newModel)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>oldModel</I><br>
<DD>

<P CLASS=para>
New value for <tt CLASS=literal>origmodel</tt> 
variable.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>newModel</I><br>
<DD>

<P CLASS=para>
New value for <tt CLASS=literal>newmodel</tt> variable. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Helper method for <tt CLASS=literal>setColorModel()</tt> 
to initialize the protected variables <tt CLASS=literal>newmodel</tt> 
and <tt CLASS=literal>origmodel</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch22-REFSECT1-AUTOID.87">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>ColorModel</tt>, <tt CLASS=literal>ImageFilter</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch22_13.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch23_01.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>ReplicateScaleFilter <img src="gifs/bstar.gif" alt="(New)" border=0></td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.awt.peer Reference</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
